/*

import java.util.Arrays;

public class Test {
    public static void main(String[] args){
        int[] arr = new int[]{122,12,23,41};
        Arrays.sort(arr);
        String str = myToString(arr);
        System.out.println(str);
    }
    public static String myToString(int[]array){
        if(array == null){
            return null;
        }
        String ret = "[";
        for (int i = 0; i < array.length; i++) {
            ret += array[i];
            if(i<array.length-1){
                ret += ", ";
            }
        }
        ret += "]";
        return ret;
    }
}
*/
//汉诺塔
/*
import java.util.Scanner;
public class Test {
    static int count = 0;
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        move(n,'A','B','C');
        System.out.println(count);

    }
    public static void move(int n,char ca,char cb, char cc){
        if(n == 1){
            count++;
            System.out.printf("%c-->%c\n",ca,cc);
        }else {
            //n-1从ca借助cc移到cb
            move(n-1,ca,cc,cb);
            //1 从ca移到cc
            move(1,ca,cb,cc);
            //n-1 从cb借助ca移到cc
            move(n-1,cb,ca,cc);
        }
    }
}*/
/*
public class Test{
    public static void getNext(String sub,int[]next){
        next[0]=-1;
        next[1]=0;
        int i=2;
        int k=0;
        for(;i<sub.length();i++) {
            if(k == -1 || sub.charAt(i-1) == sub.charAt(k)){
                next[i] = k+1;
                i++;
                k++;
            }
            else {
                k = next[k];
            }
        }
    }
    public static int KMP(String str,String sub,int pos){
        if(str == null || sub == null) return -1;
        int lenStr = str.length();
        int lenSub = str.length();
        if(lenStr == 0 || lenSub == 0) return -1;
        if(pos <= 0 || pos >=lenStr) return -1;

        int i = pos;
        int j = 0;
        int[] next=new int[lenSub];
        getNext(sub,next);

        while(i<lenStr && j<lenSub){
            if(j == -1 || str.charAt(i) == sub.charAt(j)){
                i++;
                j++;
            }
            else{
                j = next[j];
            }
        }
        if(j>=lenSub){
            return i-j;
        }
        return -1;
    }
    public static void main(String[] args){
        System.out.println(KMP("abababcda","abc", 0));
    }
}*/

//汉诺塔
/*

import java.util.Scanner;
public class Test{
    public static void move(int n,char pos1, char pos2, char pos3){
        if(n==1){
            System.out.println(pos1+"-->"+pos2);
            return ;
        }
        move(n-1,pos1,pos3,pos2);
        move(1,pos1,pos2,pos3);
        move(n-1,pos2,pos1,pos3);
    }
    public static void main(String [] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        move(n,'A','B','C');
    }
}
*/
/*

public class Test{
    public static int binarySearch(int[] array,int target){
        int left = 0;
        int right = array.length;
        while(left<=right){
            int mid = (left + right)/2;
            if(array[mid]>target){
                right = mid - 1;
            }else if(array[mid]<target) {
                left = mid + 1;
            }else {
                return mid;
            }
        }
        return -1;
    }
    public static void main(String[] args){
        int []arr={1,2,3,4,5,6,7,8,9,10};
        int ret1 = binarySearch(arr,1);
        int ret2 = binarySearch(arr,5);
        int ret3 = binarySearch(arr,6);
        int ret4 = binarySearch(arr,10);
        System.out.println(ret1);
        System.out.println(ret2);
        System.out.println(ret3);
        System.out.println(ret4);
    }
}
*/

//摩尔投票法求众数问题
/*
class Solution {
    public int majorityElement(int[] nums) {
        //假设众数是nums[0]
        int x = nums[0];
        int sum = 1;
        for(int i =1;i < nums.length; i++){
            //刷新x
            if(sum == 0){
                x = nums[i];
                sum ++;
            }else {
                if(x == nums[i]){
                    sum++;
                }else {
                    sum--;
                }
            }
        }
        return x;
    }
}*/


import java.lang.reflect.Array;
import java.util.Arrays;
/*
import java.util.Arrays;

class Solution {
    public int majorityElement(int[] nums) {
        Arrays.sort(nums);
        return nums[nums.length/2];
    }
}*/
/*
public class Test {
    public static void main(String[]args){
        int[] arr1={1,2,3,4};
        int[] arr2={10,2,3,4};
        System.out.println(Arrays.equals(arr1,arr2));
        int[] arr3 = new int[5];
        Arrays.fill(arr3,0,4,10);
        System.out.println(Arrays.toString(arr3));
    }
}*/

/*
public class Test {
    public static void main(String[] args){
        int[] arr={1,2,3,4};
        //拷贝数组，可以用来扩容
        *//*int[] arr2 =Arrays.copyOf(arr,arr.length*2);
        System.out.println(Arrays.toString(arr2));
        System.out.println(Arrays.toString(copy));*//*
        //int[] copy=Arrays.copyOfRange(arr,0,3);

        int[] copy = new int[5];
        System.arraycopy(arr,0,copy,1,arr.length);
        System.out.println(Arrays.toString(copy));
    }
}*/

/*

public class Test{
    public static void main(String[] args) {
        int[][] array = new int[2][];
        array[1] = new int[]{4,5};
        array[0] = new int[]{1,2,3};
        System.out.println(Arrays.deepToString(array));
    }

    public static void main3(String[] args){
        int[][]array={{1,2,3},{4,5,6}};
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j]+" ");
            }
            System.out.println();
        }
        System.out.println(Arrays.deepToString(array));
        for(int[] ret:array){
            for(int x:ret){
                System.out.print(x+" ");
            }
            System.out.println();
        }
    }

    public static void main2(String[] args){
        int[][] array = {{1,2,3},{4,5,6}};
        //System.out.println(array[0][0]);
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 3; j++) {
                System.out.print(array[i][j]+" ");
            }
            System.out.println();
        }

    }


    public static void main1(String[] args){
        int[][] array={{1, 2, 3}, {4, 5, 6}};
        int[][] array2 = new int[][]{{1, 2, 3}, {4, 5, 6}};
        int[][] array3 = new int[2][3];
        //行不可以省略
        //int[][] array4 = new int[][3];

        //不规则二维数组
        int[][] array5 = new int [2][];
    }
}
*/
/*

class Person{
    //属性
    public String name;
    public int age;
    //方法
    public void sleep(){

    }
}

class PetDog{
    public String name;
    public String color;
    public void barks(){
        System.out.println(name+":汪汪汪");
    }
    public void wag(){
        System.out.println(name+":摇尾巴");
    }
}

public class Test {
    public static void main(String[] args) {
        PetDog petdog = new PetDog();
        petdog.name = "hechengfeng";
        petdog.color = "red";
        petdog.wag();
        petdog.barks();
    }
}

*/
/*

class Data{
    public int year;
    public int month;
    public int day;

    public void setData(Data this,int y,int m,int d){
        this.year = y;
        this.month = m;
        this.day = d;
    }
    public void showData(){
        System.out.println(year+"-"+month+"-"+day);
    }
}

public class Test {
    public static void main(String[] args) {
        Data data = new Data();
        data.setData(2023,7,29);
        data.showData();
    }
}
*/

/*
public class Test {
    public static void main(String[] args) {
        int[] arr={4,1,2,1,2};
        int ret = 0;
        for (int i = 0; i < arr.length; i++) {
            ret^=arr[i];
        }
        System.out.println(ret);
    }
}*/
/*
public class Test{
    public static void main(String[]args){
        int[] arr={2,2,1,1,1,2,2};
        int x = arr[0];
        int sum = 1;
        for (int i = 1; i < arr.length; i++) {
            if(sum == 0){
                x = arr[i];
            }else {
                if(x == arr[i]){
                    sum++;
                }else {
                    sum--;
                }
            }
        }
        System.out.println(x);
    }
}*/

public class Test {
    public static void main(String[] args) {

        //int[4] array = {1,2,3,4};

        //int array[] = {1,2,3,4};

        //int ret=array[1];

        //int[] array = new int[4];
        //默认会将数组进行初始化为0，{0，0，0，0}

        int[] array = {1,2,3,4};
        for (int i = 0; i < array.length; i++) {
            System.out.println(array[i]);
        }

        /*for(int x:array){
            System.out.println(x);
        }*/

    }
}










